package generators;

import gamebackend.Block;

import java.util.Random;

public class VerticalStreakGenerator extends AbstractRandomGenerator implements BlockGenerator {
	public VerticalStreakGenerator(final Block the_block, final Random the_random, final double the_chance) {
		super(the_block, the_random, the_chance);
	}
	public VerticalStreakGenerator(final Random the_random, final double the_chance) {
		super(null, the_random, the_chance);
	}
	public void generate(Block[][] blocks) {
		for (int col = 0; col < blocks[1].length; col++) {
			if (blocks[1][col] == Block.EMPTY_BLOCK
					&& (blocks[0][col].isOccupied() && getRandom().nextDouble() < getChance())) {
				Block block = getBlock();
				if (block == null) {
					block = blocks[0][col];
				}
				blocks[1][col] = block;
			}
		}
	}
}
